package Thread.Demo12Daemon;

/**
 * @Author wangzhipeng
 * @Date 2020-08-20 3:39 下午
 * @Description 测试守护线程
 * 上帝守护你
 */
public class TestDemo {
    public static void main(String[] args) {
        God god = new God();
        You you = new You();

        Thread thread = new Thread(god);
        thread.setDaemon(true);

        thread.start();

        new Thread(you).start();



    }
}

//上帝
class God implements Runnable{
    @Override
    public void run() {
        while (true)
            System.out.println("上帝保佑你");
    }
}

//你
class You implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i<36500;i++){
            System.out.println("你 一生都会很开心");
        }
        System.out.println("-------goodbye！world");
    }
}
